<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>HTML5MockStorage (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">storage.mechanism.HTML5MockStorage</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="class_goog_storage_mechanism_HTML5WebStorage.html">
          goog.storage.mechanism.HTML5WebStorage
</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Provides an HTML5WebStorage wrapper for MockThrowableStorage.


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_storage_mechanism_html5webstorage_test.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/storage/mechanism/html5webstorage_test.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td><span class="type"><a href="class_goog_storage_mechanism_Mechanism.html">goog.storage.mechanism.Mechanism</a></span></td><td></td></tr>
  <tr><td><span class="type"><a href="class_goog_storage_mechanism_IterableMechanism.html">goog.storage.mechanism.IterableMechanism</a></span></td><td><span class="type"><a href="class_goog_storage_mechanism_Mechanism.html">goog.storage.mechanism.Mechanism</a></span></td></tr>
  <tr><td><span class="type"><a href="class_goog_storage_mechanism_HTML5WebStorage.html">goog.storage.mechanism.HTML5WebStorage</a></span></td><td><span class="type"><a href="class_goog_storage_mechanism_IterableMechanism.html">goog.storage.mechanism.IterableMechanism</a></span></td></tr>
  <tr><td>goog.storage.mechanism.HTML5MockStorage</td><td><span class="type"><a href="class_goog_storage_mechanism_HTML5WebStorage.html">goog.storage.mechanism.HTML5WebStorage</a></span></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.storage.mechanism.HTML5MockStorage(<span></span>)
  </div>



<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_storage_mechanism_HTML5WebStorage.html">
              goog.storage.mechanism.HTML5WebStorage
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.__iterator__"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">__iterator__<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line132">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.clear"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">clear<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line157">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.get"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">get<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line105">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.getCount"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getCount<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line126">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.isAvailable"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isAvailable<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Determines whether or not the mechanism is available.
It works only if the provided web storage object exists and is enabled.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            True if the mechanism is available.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line65">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.key"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">key<span class="args">(<span class="arg">index</span>)</span>
        </span>
        &#8658; <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Gets the key for a given key index. If an index outside of
[0..this.getCount()) is specified, this function returns null.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">index</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">A key index.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            A storage key, or null if the specified index is out of
    range.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line169">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.remove"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">remove<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line120">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.HTML5WebStorage.prototype.set"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">set<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line85">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_storage_mechanism_IterableMechanism.html">
              goog.storage.mechanism.IterableMechanism
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.IterableMechanism.prototype.__iterator__"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">__iterator__<span class="args">(<span class="arg">opt_keys</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span>
      </div>


     <div class="entryOverview">
       Returns an iterator that iterates over the elements in the storage. Will
throw goog.iter.StopIteration after the last element.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_keys</span>
        : <span class="type">boolean=</span>
        <div class="entryOverview">True to iterate over the keys. False to iterate
    over the values.  The default value is false.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span>&nbsp;
            The iterator.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_iterablemechanism.js.source.html#line70">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.IterableMechanism.prototype.clear"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">clear<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Remove all key-value pairs.

Could be overridden in a subclass, as the default implementation is not very
efficient - it iterates over all keys.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_iterablemechanism.js.source.html#line80">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.IterableMechanism.prototype.getCount"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getCount<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Get the number of stored key-value pairs.

Could be overridden in a subclass, as the default implementation is not very
efficient - it iterates over all keys.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            Number of stored elements.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_iterablemechanism.js.source.html#line52">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_storage_mechanism_Mechanism.html">
              goog.storage.mechanism.Mechanism
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.Mechanism.prototype.get"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">get<span class="args">(<span class="arg">key</span>)</span>
        </span>
        &#8658; <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Get the value stored under a key.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">key</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The key to get.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            The corresponding value, null if not found.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_mechanism.js.source.html#line48">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.Mechanism.prototype.remove"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">remove<span class="args">(<span class="arg">key</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Remove a key and its value.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">key</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The key to remove.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_mechanism.js.source.html#line56">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.storage.mechanism.Mechanism.prototype.set"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">set<span class="args">(<span class="arg">key</span>,&nbsp;<span class="arg">value</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Set a value for a key.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">key</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The key to set.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">value</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The string to save.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_mechanism.js.source.html#line39">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_storage_mechanism_HTML5MockStorage.html">
              goog.storage.mechanism.HTML5MockStorage
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.storage.mechanism.HTML5MockStorage.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage_test.js.source.html#line76">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_storage_mechanism_HTML5WebStorage.html">
              goog.storage.mechanism.HTML5WebStorage
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.storage.mechanism.HTML5WebStorage.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line38">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.storage.mechanism.HTML5WebStorage.prototype.storage_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">storage_</span>
        : 
     </div>


     <div class="entryOverview">
       The web storage object (window.localStorage or window.sessionStorage).

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage.js.source.html#line45">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_storage_mechanism_IterableMechanism.html">
              goog.storage.mechanism.IterableMechanism
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.storage.mechanism.IterableMechanism.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_iterablemechanism.js.source.html#line37">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>










<div class="section">
  <table class="horiz-rule">


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.storage.mechanism.HTML5MockStorage.superClass_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.storage.mechanism.HTML5MockStorage.</span><span class="entryName">superClass_</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_storage_mechanism_html5webstorage_test.js.source.html#line76">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package storage.mechanism</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="storage.mechanism.HTML5MockStorage"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
